//
//  WJNaviController.m
//  weibo
//
//  Created by 王俊 on 15/12/25.
//  Copyright © 2015年 王俊. All rights reserved.
//

#import "WJNaviController.h"
#import "UIBarButtonItem+WJUIBarButtonItemExt.h"

@interface WJNaviController ()

@end

@implementation WJNaviController

+ (void)initialize
{
//    if (self == [WJNaviController class]) {
//        //[self setNaviBarTitle];
//    }
    UIBarButtonItem *item = [UIBarButtonItem appearance];
    NSMutableDictionary *normalDict = [[NSMutableDictionary  alloc]init];
    normalDict[NSForegroundColorAttributeName] = [UIColor orangeColor];
    normalDict[NSFontAttributeName] = [UIFont systemFontOfSize:13];
    [item setTitleTextAttributes:normalDict forState:UIControlStateNormal];
    
    NSMutableDictionary *disaDict = [[NSMutableDictionary alloc]init];
    disaDict[NSForegroundColorAttributeName] = [UIColor lightGrayColor];
    disaDict[NSFontAttributeName] = [UIFont systemFontOfSize:13];
    [item setTitleTextAttributes:disaDict forState:UIControlStateDisabled];
    
    
}

- (void)viewDidLoad
{
    [super viewDidLoad];

}

+ (void)setNaviBarTitle
{
    NSArray *array = [[NSArray alloc]initWithObjects:[WJNaviController class], nil];
    UINavigationBar *bar = [UINavigationBar appearanceWhenContainedInInstancesOfClasses:array];
    NSMutableDictionary *dict = [NSMutableDictionary dictionary];
    dict[NSFontAttributeName] = [UIFont boldSystemFontOfSize:20];
    [bar setTitleTextAttributes:dict];
}

+ (void)setNaviBarButton
{
    UIBarButtonItem *barButton = [UIBarButtonItem appearance];
    NSMutableDictionary *disDicM = [NSMutableDictionary dictionary];
    disDicM[NSForegroundColorAttributeName] = [UIColor grayColor];
    [barButton setTitleTextAttributes:disDicM forState:UIControlStateDisabled];
    
    NSMutableDictionary *enDicM = [NSMutableDictionary dictionary];
    enDicM[NSForegroundColorAttributeName] = [UIColor orangeColor];
    [barButton setTitleTextAttributes:enDicM forState:UIControlStateNormal];
    
}

- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    if (self.childViewControllers.count) {
        viewController.hidesBottomBarWhenPushed = true;
        UIBarButtonItem *popPre = [UIBarButtonItem barButtonItemWithImage:[UIImage imageNamed:@"navigationbar_back"] highlightedImage:[UIImage imageNamed:@"navigationbar_back_highlighted"] target:self action:@selector(naviBackBtnClicked)];
        viewController.navigationItem.leftBarButtonItem = popPre;
        
        UIBarButtonItem *popRoot = [UIBarButtonItem barButtonItemWithImage:[UIImage imageNamed:@"navigationbar_more"] highlightedImage:[UIImage imageNamed:@"navigationbar_more_highlighted"] target:self action:@selector(naviBackToRoot)];
        viewController.navigationItem.rightBarButtonItem = popRoot;
    }
    [super pushViewController:viewController animated:true];
}

- (void)naviBackBtnClicked
{
    [self popViewControllerAnimated:true];
    
}

- (void)naviBackToRoot
{
    [self popToRootViewControllerAnimated:true];
}


@end
